﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LanguageInfo.Entity;
using LanguageInfo.Common.Utilities;
using LanguageInfo.Common.Enum;

namespace LanguageInfo.BLL
{
    public static class MenuInfoBll 
    {
        private static List<MenuTypeEntity> menuTypeEntity;
        public static List<MenuTypeEntity> MenuTypeEntity
        {
            get
            {
                if (menuTypeEntity == null)
                {
                    menuTypeEntity = GetMenuTypeALL();
                    return menuTypeEntity;
                }
                else
                {
                    return menuTypeEntity;
                }
            }
            set
            {
                MenuTypeEntity = value;
            }
        }

        public static List<MenuTypeEntity> GetMenuType(UserInfoEnum.UserRoleType strUserRole)
        {
            List<MenuTypeEntity> objList = MenuInfoBll.MenuTypeEntity;
            if (strUserRole != UserInfoEnum.UserRoleType.RoleTypeAdmin)
            {
                objList = objList.Where(i => i.Id != Convert.ToString((int)MenuEnum.MenuFirstType.UserInfo)).ToList();
            }

            return objList;
        }

        private static List<MenuTypeEntity> GetMenuTypeALL()
        {
            List<MenuTypeEntity> objList = new List<MenuTypeEntity>();
            List<EnumsEntity> MeunEnumType = EnumsHepler.GetEnumsToEntityList(typeof(MenuEnum.MenuFirstType));
            for (int i = 0; i < MeunEnumType.Count; i++)
            {
                MenuTypeEntity objMenuType = new MenuTypeEntity();
                objMenuType.Id = MeunEnumType[i].Value.ToString();
                objMenuType.Name = MeunEnumType[i].Text.ToString();
                List<MeunSecondEntity> MeunSecEntList = new List<MeunSecondEntity>();
                
                if (MeunEnumType[i].Value == (int)MenuEnum.MenuFirstType.CorporaInfo)
                {
                    GetMeunItem(MeunSecEntList, "6", "简单检索", "../CorporaInfo/CorporaIndex.aspx");

                    GetMeunItem(MeunSecEntList, "7", "复合检索", "../CorporaInfo/ComSearchCorp.aspx");//

                    GetMeunItem(MeunSecEntList, "3", "语料编辑", "../CorporaInfo/CorporaEdit.aspx");

                    GetMeunItem(MeunSecEntList, "4", "批量导入", "../CorporaInfo/CorporaBatchInputData.aspx");

                    GetMeunItem(MeunSecEntList, "8", "语料统计", "../CorporaInfo/CorporaStatistics.aspx");//
                }
                else if (MeunEnumType[i].Value == (int)MenuEnum.MenuFirstType.WordsInfo)
                {
                    GetMeunItem(MeunSecEntList, "4", "属性查询", "../WordsInfo/WordsIndex.aspx");

                    GetMeunItem(MeunSecEntList, "5", "编辑录入", "../WordsInfo/WordAttrEdit.aspx");

                    //GetMeunItem(MeunSecEntList, "6", "属性编辑", "../WordsInfo/WordsEdit.aspx");//

                    GetMeunItem(MeunSecEntList, "6", "属性统计", "../WordsInfo/WordsEdit.aspx");//
                }
                else if (MeunEnumType[i].Value == (int)MenuEnum.MenuFirstType.UserInfo)
                {
                    GetMeunItem(MeunSecEntList, "0", "个人信息", "../User/PersonalInfo.aspx");

                    GetMeunItem(MeunSecEntList, "1", "用户管理", "../User/MangaeUser.aspx");//

                    GetMeunItem(MeunSecEntList, "2", "数据备份", "../User/DataBackup.aspx");//

                    GetMeunItem(MeunSecEntList, "3", "数据恢复", "../User/DataRecovery.aspx");//
                }
                else if (MeunEnumType[i].Value == (int)MenuEnum.MenuFirstType.AboutUs)
                {
                    GetMeunItem(MeunSecEntList, "0", "系统介绍", "About.aspx");//

                    GetMeunItem(MeunSecEntList, "1", "联系我们", "ContactUs.aspx");//
                }
              
                objMenuType.MeunSecEntList = MeunSecEntList;
                objList.Add(objMenuType);
            }
            return objList;
        }

        private static void GetMeunItem(List<MeunSecondEntity> _MeunSecEntList,string _StrId,string _Name,string _Url)
        {
            MeunSecondEntity objUrl6 = new MeunSecondEntity();
            objUrl6.Id = _StrId;
            objUrl6.Name = _Name;
            objUrl6.Url = _Url;
            _MeunSecEntList.Add(objUrl6);
        }
    }
}
